{% extends 'base.html' %}
{% block body %}
    <div>
        {% if article_list %}
            <div class="layui-row layui-col-space15">
                {% for article in article_list %}
                    <div class="layui-col-md3">
                      <div class="layui-card">
                          <div class="layui-card-header"><a href="{% url 'article:detail' article.id %}"><h2>{{ article.title }}</h2></a></div>
                        <div class="layui-card-body">
                          <img src="/media/{{ article.coverImage }}" alt="" width="80px" height="80px"><br>
                            <span>作者：{{ article.author }}</span> <span>发布时间：{{ article.createTime }}</span>
                            {% if article.Category %}
                                <span>分类：<a href="{% url 'article:category' article.Category.id %}">{{ article.Category.category }}</a></span>
                            {% endif %}
                        </div>
                      </div>
                    </div>
<!--            <li>-->
<!--                <img src="/media/{{ article.coverImage }}" alt="" width="80px" height="80px">-->
<!--                <a href="{% url 'article:detail' article.id %}">{{ article.title }}</a>-->
<!--                {{ article.author }} {{ article.createTime }}-->
<!--                {% if article.Category %}-->
<!--                    <a href="{% url 'article:category' article.Category.id %}">{{ article.Category.category }}</a>-->
<!--                {% endif %}-->
<!--            </li>-->
                {% endfor %}
            </div>
        {% else %}
            <p>没有发布文章</p>
        {% endif %}
    </div>
    <div class="layui-row layui-col-space15">
        <div class="layui-btn-container">
            <span class="step-links">
                {% if page_obj.has_previous %}
                <a href="?page=1"><button class="layui-btn layui-btn-primary layui-border">&laquo; 首页</button></a>
                <a href="?page={{ page_obj.previous_page_number }}"><button class="layui-btn layui-btn-primary layui-border">上一页</button></a>
                {% endif %}

                {% for i in page_obj.paginator.page_range %}
                    {% if i == page_obj.number %}
                        <button type="button" class="layui-btn layui-btn-disabled">{{ i }}</button>
                    {% else %}
                        <a href="?page={{ i }}"><button class="layui-btn layui-btn-primary layui-border">{{ i }}</button></a>
                    {% endif %}
                {% endfor %}

                {% if page_obj.has_next %}
                <a href="?page={{ page_obj.next_page_number }}"><button class="layui-btn layui-btn-primary layui-border">下一页</button></a>
                    <a href="?page={{ page_obj.paginator.num_pages }}"><button class="layui-btn layui-btn-primary layui-border">尾页 &raquo;</button></a>
                {% endif %}
            </span>
        </div>
    </div>
    {% block all %} {% endblock %}
{% endblock %}